<!doctype html>
<html>

	<head>
		<meta charset="utf-8">
		<title></title>
		<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
		<link href="css/mui.css" rel="stylesheet" />
		<link href="css/login.css" rel="stylesheet" />
	</head>

	<body>
		<script src="js/mui.js"></script>
		<script type="text/javascript">
			mui.init()
		</script>
		<div class="mui-content">
			<header class="mui-bar mui-bar-nav">
				<a class="mui-action-back mui-icon mui-icon-left-nav mui-pull-left"></a>
				<h1 class="mui-title">注册</h1>
			</header>
			<form class="mui-input-group form_input">
				<div class="mui-input-row">
					<label>昵称</label>
					<input id="u_name" type="text" class="mui-input-clear name" placeholder="请输入昵称" name="name" id="" value="" />
				</div>
				<div class="mui-input-row">
					<label>邮箱</label>
					<input id="u_email" type="text" class="mui-input-clear email" placeholder="请输入邮箱" name="email" id="" value="" />
				</div>
				<div class="mui-input-row">
					<label>密码</label>
					<input id="u_password" type="password" class="mui-input-password password" placeholder="请输入密码" name="email" id="" value="" />
				</div>
				<div class="mui-button-row submit">
					<button id="register_btn" type="button" class="mui-btn mui-btn-primary">注册</button>
					<button id="exit_btn" type="button" class="mui-btn mui-btn-danger">取消</button>
				</div>
			</form>
			
			<div id="forword">
				<a class="f2" id="f" style="margin-left: 255px;">遇到问题?</a>
			</div>
		</div>
		
		<script type="text/javascript">
			
			document.getElementById('f').addEventListener('tap',function(){
				mui.openWindow({
					url: 'help_page.html',
					id: 'help_page.html',
				})
			})
			
			
			document.getElementById('register_btn').addEventListener('tap',function(){
				var email = document.getElementById('u_email').value;
				var password = document.getElementById('u_password').value;
				var username = document.getElementById('u_name').value;
				mui.ajax(localStorage.getItem('request_url')+'cost/user/register/',{
				    data:"email=" + email + "&password=" + password + "&username=" + username,
				    dataType:'json',  
				    type:'post',  
				    contentType:"application/x-www-form-urlencoded; charset=utf-8",  
				    timeout:60000,  
				    success:function show(e){
						mui.alert('注册成功，很高兴与您相遇~');
						mui.back();
					},  
				    error:function(xhr,type,errorThrown){
				        // mui.toast(typeof xhr.responseText)
				        var data = JSON.parse(xhr.responseText)
				        if (data.code==0){
				        	mui.toast('注册失败,您输入信息不符合我们的约定哦')
				        }else{
				        	mui.toast(data.msg)
				        	mui.toast(data.data.rule,{ duration:'long'})
				        }
				    }  
				});
			});
			
			document.getElementById('exit_btn').addEventListener('tap', function(){
				mui.back();
			});
			
		</script>
	</body>

</html>

